package com.loie.datacenter;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import com.loie.datacenter.comm.ExcelConst;
import com.loie.datacenter.model.stockpo.MaxDrawdownResult;
import com.loie.datacenter.model.stockpo.Nbhsprofit;
import com.loie.datacenter.model.stockpo.TradeLog;
import com.loie.datacenter.model.stockpo.TradeResult;
import com.loie.datacenter.util.ExcelCommon;
import com.loie.datacenter.util.ExcelFilenameUtil;
import com.loie.datacenter.util.ExcelUtil;
import com.loie.datacenter.util.GridTradingBacktest;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
import lombok.extern.slf4j.Slf4j;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StringUtils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


/**
 * @author: kw
 * @description: 签名连通测试
 * @create: 2021/11/18 15:16
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@MapperScan("com.loie.datacenter.mapper")

public
class excel_test {










    private static final Logger logapp = LoggerFactory.getLogger("applog");

    @Test
    public void test_item_sql() throws IOException {
//        String fromrq="2022-01-01";
//        String torq="2022-12-31";
        //List<QuotationsLine>  dataList=quotationsLineService.getsell_well_items(fromrq,torq);
        //System.out.println(dataList);
        BASE64Encoder base64Encoder = new BASE64Encoder();
        String str=base64Encoder.encode("empty".getBytes());
        System.out.println(str);
        BASE64Decoder base64Decoder = new BASE64Decoder();
        byte[] imageData = base64Decoder.decodeBuffer(str);
        String utf_8 = new String(imageData, StandardCharsets.UTF_8);
        System.out.println(utf_8);



    }







    @Test
    public
    void base64_decode() {
//        String str = "77u/dXNlcw0KICBTeXNVdGlscywgVmFyaWFudHMsIENsYXNzZXMsIGN4Rmxvd0VuZ2luZSwgY3hR\n" +
//                "dWVyeTsNCg0KcHJvY2VkdXJlIERvQ2FsY0V4ZWN1dG9yUmFuZ2UoU2VuZGVyOiBUT2JqZWN0OyB2\n" +
//                "YXIgQVJlc3VsdDogc3RyaW5nKTsNCnZhcg0KIFE6IFRjeFF1ZXJ5Ow0KYmVnaW4NCiAgUSA6PSBU\n" +
//                "Y3hRdWVyeS5DcmVhdGUobmlsKTsNCiAgdHJ5ICAgDQogICAgUS5TUUwuVGV4dCA6PSAnU0VMRUNU\n" +
//                "IGJtamwgRlJPTSBEaWNfRW1wbG95ZWUgV0hFUkUgRW1wbG95ZWVDSE5uYW1lID0gOkVtcGxveWVl\n" +
//                "Q0hObmFtZSc7IA0KICAgIFEuUGFyYW1CeU5hbWUoJ0VtcGxveWVlQ0hObmFtZScpLlZhbHVlIDo9\n" +
//                "IFNlbGYuUXVlcnlSZWNvcmRWYWx1ZSgn6Lef5Y2V5ZGYJyk7DQogICAgUS5PcGVuOw0KICAgIGlm\n" +
//                "IG5vdCBRLklzRW1wdHkgdGhlbiAgICAgDQogICAgICBBUmVzdWx0IDo9IFNlbGYuQ29udmVydFVz\n" +
//                "ZXJOYW1lVG9JRChRLkZpZWxkQnlOYW1lKCdibWpsJykuQXNTdHJpbmcpDQogICAgZWxzZSAgDQog\n" +
//                "ICAgICBBUmVzdWx0IDo9IFNlbGYuQ29udmVydFVzZXJOYW1lVG9JRCgn5YiY6YeR6bmPJyk7ICAg\n" +
//                "Ly/lvILluLjlpITnkIYgIA0KICBmaW5hbGx5DQogICAgRnJlZUFuZE5pbChRKTsNCiAgZW5kOw0K\n" +
//                "ZW5kOw0K";
        String str="316AD814AB9CFFC69A775F8F2A02E5DE";
        String rlt1 = new String(Base64.decode(str));
        System.out.println("new String===" + rlt1);
    }
    @Test
    public void test_datetostring(){
        String input = "2024/11/07-10:55";

        // 解析输入字符串
        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd-HH:mm");
        LocalDateTime dateTime = LocalDateTime.parse(input,  inputFormatter);

        // 转换为目标格式
        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
        String result = dateTime.format(outputFormatter);

        System.out.println(" 转换结果: " + result); // 输出: 202411071055
    }

    @Test
    public void test_loadbjtxtdate() throws Exception {
//        String stockCode;
//        String stockName;
//        String stockCode1;
//        String stockName1;
//        String subpath = "0612";
//        String filePath = "D:\\临时数据\\" + subpath;
//        stockCode = "";
//        stockName = "";
//        stockCode1 = "";
//        stockName1 = "";
//        File dir = new File(filePath);
//        if (!dir.exists() || !dir.isDirectory()) {
//            System.out.println(filePath + "目录不存在");
//
//            return;
//        }
//        File[] files = dir.listFiles();
//        List<TradeResult> tradeResultList = new ArrayList<>();
//        DecimalFormat df = new DecimalFormat("#0.00");
//        Integer i = 0;
//        for (File file : files) {
//
//            if (file.isFile() && file.getName().endsWith(".txt")) {
//                i++;
//                log.info(String.format("正在分析第：%d个数据文件/共%d个文件-文件名为：%s", i, files.length, file.getName()));
//                String filename = file.getPath();
//
//                GridTradingBacktest engine = new GridTradingBacktest();
//
//
//                if (engine.loadsingletxtData(file.getPath(), 45000)) {
//
//                }
//
//            }
//        }
    }


    @Test
    public void test_loadtxtdate() throws Exception {

//        String filePath = "D:\\临时数据\\0524\\SH#688306.txt";
        String stockCode;
        String stockName;
        String stockCode1;
        String stockName1;
        Double maxprofit = 0.0;
        Double maxprofitrate = 0.0;
        Double maxprofit1 = 0.0;
        Double maxprofitrate1 = 0.0;
        Integer i, count;
        i = 0;
        String subpath = "0803";
        List<Double> profitlist = new ArrayList<>();
        profitlist.add(1.5);
        profitlist.add(2.0);
        profitlist.add(2.5);
        profitlist.add(3.0);
        profitlist.add(3.5);
//        profitlist.add(4.0);
//        profitlist.add(4.5);
//        profitlist.add(5.0);
//        profitlist.add(5.5);
//        profitlist.add(6.0);
//        profitlist.add(6.5);
//        profitlist.add(7.0);
//        profitlist.add(7.5);
//        profitlist.add(8.0);
//        profitlist.add(8.5);
//        profitlist.add(9.0);
        for (int k = 0; k < profitlist.size(); k++) {


            String filePath = "D:\\临时数据\\" + subpath;
            stockCode = "";
            stockName = "";
            stockCode1 = "";
            stockName1 = "";
            File dir = new File(filePath);
            if (!dir.exists() || !dir.isDirectory()) {
                System.out.println(filePath + "目录不存在");

                return;
            }
            File[] files = dir.listFiles();
            List<TradeResult> tradeResultList = new ArrayList<>();
            DecimalFormat df = new DecimalFormat("#0.00");

            //execl标题
            List<JSONObject> headList = new ArrayList<>();
            List<JSONObject> mainheadList = new ArrayList<>();
//
//
            List<List<String>> lists = new ArrayList<>();
            List<List<String>> mainlists = new ArrayList<>();
            String titlestr = "股票代码,股票名称,日期,买或卖,价格,股数,剩余股数,股票总价,现金总价,总金额,获利金额,上次基准价";
            //String deststr = "corpserialno,businesscorpno,shortname,engname,chnname,buyeraddr,countrycode,regioncode,taxno,regno";
            String[] titlearr = titlestr.split(",");
            //String[] destarr = deststr.split(",");
            //List<String>titlelist= new ArrayList<>();
            for (String s : titlearr) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ExcelConst.TITLE, s);
                jsonObject.put(ExcelConst.WIDTH, 3500);
//            if (s.equals("上次基准价")){
//                jsonObject.put(ExcelConst.TYPE, "2");
//                jsonObject.put(ExcelConst.FORMAT, "#,#0.00");
//            }
//            else{
                jsonObject.put(ExcelConst.TYPE, "1");
                //}
                headList.add(jsonObject);
            }


            String maintitlestr = "股票代码,股票名称,期初价,当前价,最高价,最低价,收益,收益率,买次数,卖次数,波动率,最大回撤率,最大回撤差额,最大回撤高点,回撤时间(高),最大回撤低点,回撤时间(低)";
            //String deststr = "corpserialno,businesscorpno,shortname,engname,chnname,buyeraddr,countrycode,regioncode,taxno,regno";
            String[] maintitlearr = maintitlestr.split(",");
            //String[] destarr = deststr.split(",");
            //List<String>titlelist= new ArrayList<>();
            for (String s : maintitlearr) {
                i=0;
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ExcelConst.TITLE, s);
                jsonObject.put(ExcelConst.WIDTH, 3500);
//            if (s.equals("上次基准价")){
//                jsonObject.put(ExcelConst.TYPE, "2");
//                jsonObject.put(ExcelConst.FORMAT, "#,#0.00");
//            }
//            else{
                jsonObject.put(ExcelConst.TYPE, "1");
                //}
                mainheadList.add(jsonObject);
            }
            for (File file : files) {

                if (file.isFile() && file.getName().endsWith(".txt")) {
                    i++;
                    log.info(String.format("正在分析第：%d个数据文件/共%d个文件-文件名为：%s", i, files.length, file.getName()));
                    String filename = file.getPath();
//        File file=new File(filePath);

//        if (StringUtils.isEmpty(file))
//        {
//            System.out.println("文件不存在");
//        }
                    GridTradingBacktest engine = new GridTradingBacktest();

                    Boolean bjs = false;
                    Boolean getdata = false;
                    bjs = false;
                    String time2="2025/07/01 0600";
                    if (!bjs)
                        getdata = engine.loadtxtData(file.getPath(), 50000, 20000, profitlist.get(k), profitlist.get(k),time2,5000);
                    else
                        getdata = engine.loadsingletxtData(file.getPath(), 80000, 3000, 10, 5);
                    if (getdata) {
                        //System.out.println("初始价格:" + engine.basePrice);
                        //engine.basePrice=engine.bars.get(0).close;
                        // System.out.println(engine.bars);
//        for (Bar bar:engine.bars){
//            System.out.println(bar.getTimestamp()+"/"+bar.getClose());
//        }
                        engine.executeStrategy();
                        engine.generateReport();
                        if (engine.getFinalprofit() > 500) {
                            TradeResult tradeResult = new TradeResult();
                            tradeResult.setStockCode(engine.getStockCode());
                            tradeResult.setStockName(engine.getStockName());
                            tradeResult.setFinalprofit(Double.valueOf(df.format(engine.getFinalprofit())));
                            tradeResult.setFinalprofitrate(Double.valueOf(df.format(engine.getFinalprofitrate())));
                            tradeResult.setFirstprice(engine.getFirstprice());
                            tradeResult.setMaxprice(engine.getMaxprice());
                            tradeResult.setMinprice(engine.getMinprice());
                            tradeResult.setCurprice(engine.getCurprice());
                            tradeResult.setBuycount(engine.getBuycount());
                            tradeResult.setSellcount(engine.getSellcount());
                            tradeResult.setTradeLogList(engine.getTradeLogs());
                            tradeResult.setAnnualVolatility(engine.getAnnualVolatility());
                            tradeResult.setMaxDrawdownResult(engine.getMaxDrawdownResult());
                            tradeResultList.add(tradeResult);

                            List<TradeLog> tradeLogs = engine.getTradeLogs();


                            for (int i1 = 0; i1 <= tradeLogs.size() - 1; i1++) {
                                if (tradeLogs.get(i1).getType().equals("SELL")) {
                                    log.info("卖：" + com.alibaba.fastjson2.JSON.toJSONString(tradeLogs.get(i1)));


                                } else if (tradeLogs.get(i1).getType().equals("BUY")) {
                                    log.info("买：" + com.alibaba.fastjson2.JSON.toJSONString(tradeLogs.get(i1)));

                                }

                            }

                            log.info(String.format("股票代码:%s-名称：%s,期初价:%.2f,最高价:%.2f,最低价:%.2f,当前价:%.2f,收益:%.2f-收益率:%.2f-波动率：%.2f",
                                    engine.getStockCode(), engine.getStockName(), engine.getFirstprice(),
                                    engine.getMaxprice(), engine.getMinprice(), engine.getCurprice(),
                                    engine.getFinalprofit(), engine.getFinalprofitrate(), engine.getAnnualVolatility()));


                            if (maxprofit < engine.getFinalprofit() && engine.getFinalprofit() > 0) {
                                maxprofit = engine.getFinalprofit();
                                stockName = engine.getStockName();
                                stockCode = engine.getStockCode();
                                maxprofitrate = engine.getFinalprofitrate();
                            }
                            if (maxprofitrate1 < engine.getFinalprofitrate() && engine.getFinalprofitrate() > 0) {
                                maxprofit1 = engine.getFinalprofit();
                                maxprofitrate1 = engine.getFinalprofitrate();
                                stockName1 = engine.getStockName();
                                stockCode1 = engine.getStockCode();
                            }


                        }
                    }

                }
            }
            if (tradeResultList.size() == 0) {
                log.info("**********无符合条件的数据***********");
                return;
            }
            log.info("**********按利润排序***********");
            tradeResultList.sort(Comparator.comparing(
                    TradeResult::getFinalprofit,
                    Comparator.nullsLast(Comparator.reverseOrder())
            ));
            String json = JSON.toJSONString(tradeResultList);
            log.info("按利润排序收益超500以上的股票\n" + json);


            Integer xj = 0;
            for (TradeResult tradeResult : tradeResultList) {
                xj++;
                List<String> mainlist = new ArrayList<>();
                mainlist.add(tradeResult.getStockCode());
                mainlist.add(tradeResult.getStockName());
                mainlist.add("期初价:" + tradeResult.getFirstprice());
                mainlist.add("当前价:" + tradeResult.getCurprice());
                mainlist.add("最高价:" + tradeResult.getMaxprice());
                mainlist.add("最低价:" + tradeResult.getMinprice());
                mainlist.add("收益:" + tradeResult.getFinalprofit());
                mainlist.add("收益率:" + tradeResult.getFinalprofitrate());
                mainlist.add("买次数:" + tradeResult.getBuycount());
                mainlist.add("卖次数：" + tradeResult.getSellcount());
                mainlist.add("波动率" + String.format("%.2f", tradeResult.getAnnualVolatility()));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getMaxDrawdownPercent() * 100));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getMaxDrawdown()));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getPeakPrice()));
                mainlist.add(tradeResult.getMaxDrawdownResult().getMaxPricetime().toString());
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getTroughPrice()));
                mainlist.add(tradeResult.getMaxDrawdownResult().getTroughPricePricetime().toString());

                // lists.add(mainlist);
                mainlists.add(mainlist);
                for (TradeLog tradeLog : tradeResult.getTradeLogList()) {
                    List<String> list = new ArrayList<>();

                    list.add(tradeResult.getStockCode());
                    list.add(tradeResult.getStockName());
//                list.add("承上");
//                 list.add("承上");

                    list.add(tradeLog.getTime().toString());
                    if (tradeLog.getType().equals("SELL"))
                        list.add("卖");
                    else
                        list.add("买");
                    list.add(String.format("%.2f", tradeLog.getPrice()));
                    list.add(String.valueOf(tradeLog.getQuantity()));
                    list.add(String.valueOf(tradeLog.getStocknum()));
                    list.add(String.format("%.2f", (tradeLog.getStockamount())));
                    list.add(String.format("%.2f", (tradeLog.getCash())));
                    list.add(String.format("%.2f", (tradeLog.getTotalamout())));
                    list.add(String.format("%.2f", (tradeLog.getProfit())));
                    list.add(String.format("%.2f", (tradeLog.getBaseprice())));
                    lists.add(list);

                }
            }


            if (mainlists.size() > 0) {
                ExcelFilenameUtil.getExcel("D:\\临时数据\\" + subpath + "\\" + subpath.replace("\\","-") + "-"+profitlist.get(k)+".xlsx", mainlists, mainheadList, false, "profitmain");
            }
            if (lists.size() > 0) {
                ExcelFilenameUtil.getExcel("D:\\临时数据\\" + subpath + "\\" + subpath.replace("\\","-") + "-"+profitlist.get(k)+".xlsx", lists, headList, false, "profitsub");
            }
            log.info("*********按卖次数排序************");
            tradeResultList.sort(Comparator.comparing(
                    TradeResult::getSellcount,
                    Comparator.nullsLast(Comparator.reverseOrder())
            ));
            json = JSON.toJSONString(tradeResultList);
            log.info("按卖的次序排序收益超500以上的股票\n" + json);

            xj = 0;
            lists.clear();
            mainlists.clear();
            for (TradeResult tradeResult : tradeResultList) {
                xj++;
                List<String> mainlist = new ArrayList<>();
                mainlist.add(tradeResult.getStockCode());
                mainlist.add(tradeResult.getStockName());
                mainlist.add("期初价:" + tradeResult.getFirstprice());
                mainlist.add("当前价:" + tradeResult.getCurprice());
                mainlist.add("最高价:" + tradeResult.getMaxprice());
                mainlist.add("最低价:" + tradeResult.getMinprice());
                mainlist.add("收益:" + tradeResult.getFinalprofit());
                mainlist.add("收益率:" + tradeResult.getFinalprofitrate());
                //mainlist.add("收益率:"+tradeResult.getFinalprofitrate());
                mainlist.add("买次数：" + tradeResult.getBuycount());
                mainlist.add("卖次数：" + tradeResult.getSellcount());
                mainlist.add("波动率" + String.format("%.2f", tradeResult.getAnnualVolatility()));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getMaxDrawdownPercent() * 100));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getMaxDrawdown()));
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getPeakPrice()));
                mainlist.add(tradeResult.getMaxDrawdownResult().getMaxPricetime().toString());
                mainlist.add(String.format("%.2f", tradeResult.getMaxDrawdownResult().getTroughPrice()));
                mainlist.add(tradeResult.getMaxDrawdownResult().getTroughPricePricetime().toString());
                // lists.add(mainlist);
                mainlists.add(mainlist);

                for (TradeLog tradeLog : tradeResult.getTradeLogList()) {
                    List<String> list = new ArrayList<>();

                    list.add(tradeResult.getStockCode());
                    list.add(tradeResult.getStockName());
//                list.add("承上");
//                 list.add("承上");

                    list.add(tradeLog.getTime().toString());
                    if (tradeLog.getType().equals("SELL"))
                        list.add("卖");
                    else
                        list.add("买");
                    list.add(String.format("%.2f", tradeLog.getPrice()));
                    list.add(String.valueOf(tradeLog.getQuantity()));
                    list.add(String.valueOf(tradeLog.getStocknum()));
                    list.add(String.format("%.2f", (tradeLog.getStockamount())));
                    list.add(String.format("%.2f", (tradeLog.getCash())));
                    list.add(String.format("%.2f", (tradeLog.getTotalamout())));
                    list.add(String.format("%.2f", (tradeLog.getProfit())));
                    list.add(String.format("%.2f", (tradeLog.getBaseprice())));
                    lists.add(list);

                }
            }
//            if (mainlists.size() > 0) {
//                ExcelFilenameUtil.getExcel("D:\\临时数据\\" + subpath + "\\" + subpath + "-"+profitlist.get(k)+".xlsx", mainlists, mainheadList, false, "sellmain");
//            }
//            if (lists.size() > 0) {
//                ExcelFilenameUtil.getExcel("D:\\临时数据\\" + subpath + "\\" + subpath + "-"+profitlist.get(k)+".xlsx", lists, headList, false, "Sellsub");
//            }


            log.info(String.format("最高收益股-票代码:%s-名称：%s,收益:%.2f-收益率:%.2f", stockCode, stockName, maxprofit, maxprofitrate));
            log.info(String.format("最高收益益-股票代码:%s-名称：%s,收益:%.2f-收益率:%.2f", stockCode1, stockName1, maxprofit1, maxprofitrate1));
        }
    }


    @Test
    public void test_importjbdate() throws Exception{
        File file=new File("D:\\临时数据\\jbdata\\jb_data.xlsx");

        if (StringUtils.isEmpty(file))
        {
            System.out.println("文件不存在");
        }
        byte[] bytes = Files.readAllBytes(file.toPath());

        // 创建MockMultipartFile
        MockMultipartFile multipartFile= new MockMultipartFile(
                "file",          // 参数名
                file.getName(),   // 原始文件名
                "text/plain",    // 内容类型（根据实际文件调整）
                bytes            // 文件字节
        );
        // FileItemFactory factory = new DiskFileItemFactory(16, null);
        //FileItem item = factory.createItem(file.getName(), "text/plain", true, file.getName());
        //MultipartFile multipartFile = new CommonsMultipartFile(item);
        Set<String> key1= new HashSet<>();
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("内部核算","nbhs");
        hashMap.put("利润率","profitrate");

        List<JSONObject> results = ExcelCommon.getTestData(hashMap,multipartFile,"二部");
        System.out.println(results);
        List<Nbhsprofit>nbhsprofitList=new ArrayList<>();
        for(JSONObject json:results){
            Nbhsprofit nbhsprofit = json.toJavaObject(Nbhsprofit.class);
            nbhsprofitList.add(nbhsprofit);
        }
        System.out.println(nbhsprofitList);



    }
    @Test
    public void test_importstock() throws Exception{
        File file=new File("D:\\873706.xlsx");

        if (StringUtils.isEmpty(file))
        {
            System.out.println("文件不存在");
        }
        byte[] bytes = Files.readAllBytes(file.toPath());

        // 创建MockMultipartFile
        MockMultipartFile multipartFile= new MockMultipartFile(
                "file",          // 参数名
                file.getName(),   // 原始文件名
                "text/plain",    // 内容类型（根据实际文件调整）
                bytes            // 文件字节
        );
        // FileItemFactory factory = new DiskFileItemFactory(16, null);
        //FileItem item = factory.createItem(file.getName(), "text/plain", true, file.getName());
        //MultipartFile multipartFile = new CommonsMultipartFile(item);
        Set<String> key1= new HashSet<>();
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("时间","timestamp");
        hashMap.put("开盘","open");
        hashMap.put("最高","high");
        hashMap.put("最低","low");
        hashMap.put("收盘","close");
        List<JSONObject> results = ExcelCommon.getTestData(hashMap,multipartFile,"873706");
       // System.out.println(results);
        GridTradingBacktest engine = new GridTradingBacktest();

       if (engine.loadjsonData(results,55000)){
        System.out.println("初始价格:"+engine.basePrice);
        //engine.basePrice=engine.bars.get(0).close;
        // System.out.println(engine.bars);
//        for (Bar bar:engine.bars){
//            System.out.println(bar.getTimestamp()+"/"+bar.getClose());
//        }
        engine.executeStrategy();
        engine.generateReport();}
    }











}
